import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '赛事id',
    align:"center",
    dataIndex: 'saisId_dictText'
   },
   {
    title: '赛事进程id',
    align:"center",
    dataIndex: 'saisjcId_dictText'
   },
   {
    title: '赛事区域id',
    align:"center",
    dataIndex: 'saisqyId',
    customRender:({text}) => {
       return  render.renderCategoryTree(text,'C05')
   },
   },
   {
    title: '赛事字段',
    align:"center",
    dataIndex: 'saiszd_dictText'
   },
   {
    title: '控件数据',
    align:"center",
    dataIndex: 'kongjsj'
   },
   {
    title: '参赛人身份',
    align:"center",
    dataIndex: 'cansrsf_dictText'
   },
   {
    title: '表单控件类型',
    align:"center",
    dataIndex: 'biaodkjlx_dictText'
   },
   {
    title: '表单验证',
    align:"center",
    dataIndex: 'biaodyz_dictText'
   },
   {
    title: '是否查询',
    align:"center",
    dataIndex: 'shifcx_dictText'
   },
   {
    title: '查询控件',
    align:"center",
    dataIndex: 'chaxkj_dictText'
   },
   {
    title: '字典编码',
    align:"center",
    dataIndex: 'zidbm'
   },
   {
    title: '可见权限',
    align:"center",
    dataIndex: 'kejqx_dictText'
   },
   {
    title: '24分栏',
    align:"center",
    dataIndex: 'fenl24'
   },
   {
    title: '是否列表显示',
    align:"center",
    dataIndex: 'shiflbxs_dictText'
   },
   {
    title: '是否导出pdf',
    align:"center",
    dataIndex: 'shifdcpdf_dictText'
   },
   {
    title: '排序',
    align:"center",
    dataIndex: 'paix'
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "赛事id",
      field: 'saisId',
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"cdba2_sais,mingc,id"
      },
      //colProps: {span: 6},
 	},
	{
      label: "赛事进程id",
      field: 'saisjcId',
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"cdba2_saisjc,jincmc,id"
      },
      //colProps: {span: 6},
 	},
	{
      label: "赛事区域id",
      field: 'saisqyId',
      component: 'JCategorySelect',
      componentProps:{
          pcode:"C05",//back和事件未添加，暂时有问题
      },
      //colProps: {span: 6},
 	},
	{
      label: "赛事字段",
      field: 'saiszd',
      component: 'JSearchSelect',
      componentProps:{
         dict:"cdba2_saiszd,zidzwm2,id"
      },
      //colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '赛事id',
    field: 'saisId',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"cdba2_sais,mingc,id"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入赛事id!'},
          ];
     },
  },
  {
    label: '赛事进程id',
    field: 'saisjcId',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"cdba2_saisjc,jincmc,id"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入赛事进程id!'},
          ];
     },
  },
  {
    label: '赛事区域id',
    field: 'saisqyId',
    component: 'JCategorySelect',
    componentProps:{
       pcode:"C05", //TODO back和事件未添加，暂时有问题
    },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入赛事区域id!'},
          ];
     },
  },
  {
    label: '赛事字段',
    field: 'saiszd',
    component: 'JSearchSelect',
    componentProps:{
       dict:"cdba2_saiszd,zidzwm2,id"
    },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入赛事字段!'},
          ];
     },
  },
  {
    label: '控件数据',
    field: 'kongjsj',
    component: 'InputTextArea',
  },
  {
    label: '参赛人身份',
    field: 'cansrsf',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"canssf"
     },
  },
  {
    label: '表单控件类型',
    field: 'biaodkjlx',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"kongjlx"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入表单控件类型!'},
          ];
     },
  },
  {
    label: '表单验证',
    field: 'biaodyz',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"cbda2_baodyzgz,mingc,id"
     },
  },
  {
    label: '是否查询',
    field: 'shifcx',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"yn"
     },
  },
  {
    label: '查询控件',
    field: 'chaxkj',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"kongjlx"
     },
  },
  {
    label: '字典编码',
    field: 'zidbm',
    component: 'Input',
  },
  {
    label: '可见权限',
    field: 'kejqx',
    component: 'JSelectMultiple',
    componentProps:{
        dictCode:"sys_role,role_name,id"
     },
  },
  {
    label: '24分栏',
    field: 'fenl24',
    component: 'InputNumber',
  },
  {
    label: '是否列表显示',
    field: 'shiflbxs',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"yn"
     },
  },
  {
    label: '是否导出pdf',
    field: 'shifdcpdf',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"yn"
     },
  },
  {
    label: '排序',
    field: 'paix',
    component: 'InputNumber',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  saisId: {title: '赛事id',order: 0,view: 'list', type: 'string',dictTable: "cdba2_sais", dictCode: 'id', dictText: 'mingc',},
  saisjcId: {title: '赛事进程id',order: 1,view: 'list', type: 'string',dictTable: "cdba2_saisjc", dictCode: 'id', dictText: 'jincmc',},
  saisqyId: {title: '赛事区域id',order: 2,view: 'cat_tree', type: 'string',pcode: 'C05',},
  saiszd: {title: '赛事字段',order: 3,view: 'sel_search', type: 'string',dictTable: "cdba2_saiszd", dictCode: 'id', dictText: 'zidzwm2',},
  kongjsj: {title: '控件数据',order: 4,view: 'textarea', type: 'string',},
  cansrsf: {title: '参赛人身份',order: 5,view: 'list', type: 'string',dictCode: 'canssf',},
  biaodkjlx: {title: '表单控件类型',order: 6,view: 'list', type: 'string',dictCode: 'kongjlx',},
  biaodyz: {title: '表单验证',order: 7,view: 'list', type: 'string',dictTable: "cbda2_baodyzgz", dictCode: 'id', dictText: 'mingc',},
  shifcx: {title: '是否查询',order: 8,view: 'list', type: 'string',dictCode: 'yn',},
  chaxkj: {title: '查询控件',order: 9,view: 'list', type: 'string',dictCode: 'kongjlx',},
  zidbm: {title: '字典编码',order: 10,view: 'text', type: 'string',},
  kejqx: {title: '可见权限',order: 11,view: 'list_multi', type: 'string',dictTable: "sys_role", dictCode: 'id', dictText: 'role_name',},
  fenl24: {title: '24分栏',order: 12,view: 'number', type: 'number',},
  shiflbxs: {title: '是否列表显示',order: 13,view: 'list', type: 'string',dictCode: 'yn',},
  shifdcpdf: {title: '是否导出pdf',order: 14,view: 'list', type: 'string',dictCode: 'yn',},
  paix: {title: '排序',order: 15,view: 'number', type: 'number',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}